home *** CD-ROM | disk | FTP | other *** search
- property playerstate : "off"
-
- tell application "Finder"
- set x to name of every process
- end tell
-
- if ("iChat" is not in x) then
- return null
- end if
-
- if ("MulleSight" is in x) then
-
- tell application "iChat"
- set image to image of application "MulleSight"
- end tell
- end if
-
- if ("iTunes" is not in x) then
- return null
- end if
-
- tell application "iTunes"
- if player state is stopped then
- if playerstate is not "stopped" then
- set playerstate to "stopped"
- return "Quiet"
- end if
- return null
- end if
-
- set trackkind to kind of current track
- set trackname to name of current track
- set trackpos to "00:00"
- if player position > 0 then
- set trackpos to ""
- set p to player position
- set hr to p div 3600
- set min to (p div 60) - (hr * 60)
- set sec to (((p / 60) - (p div 60)) * 60) div 1
- if (min < 10) then set min to "0" & min
- if (sec < 10) then set sec to "0" & sec
- if character 2 of (sec as string) = "8" then set sec to sec & " "
- if hr > 0 then set trackpos to hr & ":"
- set trackpos to trackpos & min & ":" & sec
- end if
-
- set prefix to ""
- set title to null
- if player state is paused then set prefix to "Paused: "
- if mute then set prefix to "Muted: "
- if sound volume = 0 then set prefix to "Silent: "
- if size of current track is missing value and time of current track is missing value then
- set trackaddr to address of current track
- set trackgenre to genre of current track
- set myurl to null
- if trackname contains "somewhere.com" then set myurl to "http://www.somewhere.com:8000/list.cgi"
- if trackname contains "grassyhill.org" then set myurl to "http://radio.grassyhill.org"
- if myurl is not null then
- set tmpfile to ((path to temporary items) as string) & "cursong.txt"
- --if exists file tmpfile then
- --tell application "Finder" to delete file tmpfile
- --end if
- tell application "URL Access Scripting"
- download myurl to file tmpfile replacing yes
- end tell
- set tfile to open for access file tmpfile
-
- set fcontents to read tfile using delimiter {"<", ">"}
- close access tfile
- --tell application "Finder" to delete file tmpfile
- end if
- if trackname contains "somewhere.com" then
- set taglist to {"Title", "tr", "localhost"}
- repeat with i from 1 to number of items in fcontents
- if item i of fcontents is item 1 of taglist then
- if number of items in taglist = 1 then
- set title to ((item (i + 12) of fcontents) as string) & " - " & "ns2.somewhere.com:8000/remote"
- exit repeat
- else
- set taglist to (items 2 thru (number of items in taglist)) of taglist
- end if
- end if
- end repeat
- else if trackname contains "grassyhill.org" then
- repeat with i from 1 to number of items in fcontents
- if item i of fcontents contains "Now Playing:" then
- repeat with j from i + 1 to i + 40
- if item j of fcontents contains "/A" then
- set tmp to (item (j + 1) of fcontents) as string
-
- if last character of tmp is ")" then
- repeat while last character of tmp is not "("
- set tmp to (characters 1 thru ((length of tmp) - 1) of tmp) as string
- end repeat
- set tmp to (characters 1 thru ((length of tmp) - 2) of tmp) as string
- end if
- set title to ((item (j - 1) of fcontents) as string) & tmp & " - " & trackaddr
- exit repeat
- end if
- end repeat
- exit repeat
- end if
- end repeat
- end if
- if title is null then
- set title to trackname & " (Elapsed: " & trackpos & ") "
- end if
- else
- set trackalbum to album of current track
- set trackartist to artist of current track
- set title to trackname & " - " & trackartist & " (" & trackalbum & ")"
- end if
-
- set title to prefix & title
- return title
- end tell
-
- on gettitle()
- set tmpfile to ((path to temporary items) as string) & "cursong.txt"
- --set tmpfile to "MacOS:tmp:cursong.txt"
- if exists tmpfile then
- tell application "Finder" to delete file tmpfile
- end if
- tell application "URL Access Scripting"
- download "http://nazgul:gryffon@www.somewhere.com:8000/admin?mode=sources" to file tmpfile replacing yes
- end tell
- set tfile to open for access file tmpfile
-
- set fcontents to read tfile using delimiter {"<", ">"}
- close access tfile
- tell application "Finder" to delete file tmpfile
- set mytitle to null
- repeat with i from 1 to number of items in fcontents
- if item i of fcontents contains "localhost" then
- set mytitle to (item (i + 4) of fcontents) as string
- exit repeat
- end if
- end repeat
- return mytitle
- end gettitle
-
- on round_truncate(this_number, decimal_places)
- if decimal_places is 0 then
- set this_number to this_number + 0.5
- return number_to_text(this_number div 1)
- end if
-
- set the rounding_value to "5"
- repeat decimal_places times
- set the rounding_value to "0" & the rounding_value
- end repeat
- set the rounding_value to ("." & the rounding_value) as number
-
- set this_number to this_number + rounding_value
-
- set the mod_value to "1"
- repeat decimal_places - 1 times
- set the mod_value to "0" & the mod_value
- end repeat
- set the mod_value to ("." & the mod_value) as number
-
- set second_part to (this_number mod 1) div the mod_value
- if the length of (the second_part as text) is less than the ¬
- decimal_places then
- repeat decimal_places - ¬
- (the length of (the second_part as text)) times
- set second_part to ("0" & second_part) as string
- end repeat
- end if
-
- set first_part to this_number div 1
- set first_part to number_to_text(first_part)
- set this_number to (first_part & "." & second_part)
-
- return this_number
- end round_truncate
-
- on number_to_text(this_number)
- set this_number to this_number as text
- if this_number contains "E+" then
- set x to the offset of "." in this_number
- set y to the offset of "+" in this_number
- set z to the offset of "E" in this_number
- set the decimal_adjust to characters (y - (length of this_number)) thru ¬
- -1 of this_number as string as number
- if x is not 0 then
- set the first_part to characters 1 thru (x - 1) of this_number as string
- else
- set the first_part to ""
- end if
- set the second_part to characters (x + 1) thru (z - 1) of this_number as string
- set the converted_number to the first_part
- repeat with i from 1 to the decimal_adjust
- try
- set the converted_number to ¬
- the converted_number & character i of the second_part
- on error
- set the converted_number to the converted_number & "0"
- end try
- end repeat
- return the converted_number
- else
- return this_number
- end if
- end number_to_text
-
-